package org.example.forum.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.example.forum.common.AppResult;
import org.example.forum.exception.ApplicationException;
import org.springframework.web.bind.annotation.*;

@Api(tags = "测试接口")
@RestController
@RequestMapping("/test")
public class TestController {
    @ApiOperation("测试接口1，测试同意异常处理")
    @GetMapping("/t1")
    public AppResult testException() throws Exception {
        throw new Exception("这是一个Exception");
    }

    @GetMapping("/t2")
    public AppResult testApplicationException() throws Exception {
        throw new ApplicationException("这是一个ApplicationException");
    }

    @PostMapping("/t3")
    @ApiOperation("按照传入的姓名显示你好信息")
    public String testHello(@ApiParam(value = "姓名") @RequestParam String name) {
        return "hello " + name;
    }
}
